安卓系统中,使用cocos2d-x开发的游戏,在系统有电话来了时,会触发AppDelegate::applicationDidEnterBackground()函数。可在这个函数里作些必要的处理,例如暂停游戏。
http://www.cnblogs.com/KevinYuen/archive/2013/03/10/2952915.html
亮点:
// 当应用程序后台化后,比如来电话也会是这个效果,那么这里的操作是:
void AppDelegate::applicationDidEnterBackground()
{
// 终止所有动画的播放,cocos2dx的操作为不进行场景渲染
CCDirector::sharedDirector()->stopAnimation();
// 背景音乐暂停
SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
}
// 当应用程序重新回到前台,一切恢复
void AppDelegate::applicationWillEnterForeground()
{
// 渲染场景
CCDirector::sharedDirector()->startAnimation();
// 背景音乐恢复播放
SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
}
英拉
HxLauncher: Launch Android applications by voice commands